/***********************************************************************
 * Module:  Predracun.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class Predracun
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class Predracun implements Serializable {
	
	protected Integer id;
	protected Date datumIzdavanjaPredracuna;
	protected Date datumVazenjaPonude;
	protected int redniBrojPredracuna;
	protected int verzija;

	protected Collection<NarucenaUsluga> naruceneUsluge;

	public Collection<NarucenaUsluga> getNaruceneUsluge() {
		if (naruceneUsluge == null)
			naruceneUsluge = new HashSet<NarucenaUsluga>();
		
		return naruceneUsluge;
	}

	public Iterator<NarucenaUsluga> getIteratorNaruceneUsluge() {
		if (naruceneUsluge == null)
			naruceneUsluge = new HashSet<NarucenaUsluga>();
		
		return naruceneUsluge.iterator();
	}

	public void setNaruceneUsluge(Collection<NarucenaUsluga> newNaruceneUsluge) {
		removeAllNaruceneUsluge();
		for (Iterator<NarucenaUsluga> iter = newNaruceneUsluge.iterator(); iter.hasNext();)
			addNarucenaUsluga((NarucenaUsluga) iter.next());
	}

	public void addNarucenaUsluga(NarucenaUsluga newNarucenaUsluga) {
		if (newNarucenaUsluga == null)
			return;
		if (this.naruceneUsluge == null)
			this.naruceneUsluge = new HashSet<NarucenaUsluga>();
		if (!this.naruceneUsluge.contains(newNarucenaUsluga))
			this.naruceneUsluge.add(newNarucenaUsluga);
	}

	public void removeNarucenaUsluga(NarucenaUsluga oldNarucenaUsluga) {
		if (oldNarucenaUsluga == null)
			return;
		if (this.naruceneUsluge != null)
			if (this.naruceneUsluge.contains(oldNarucenaUsluga))
				this.naruceneUsluge.remove(oldNarucenaUsluga);
	}

	public void removeAllNaruceneUsluge() {
		if (naruceneUsluge != null)
			naruceneUsluge.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getDatumIzdavanjaPredracuna() {
		return datumIzdavanjaPredracuna;
	}

	public void setDatumIzdavanjaPredracuna(Date datumIzdavanjaPredracuna) {
		this.datumIzdavanjaPredracuna = datumIzdavanjaPredracuna;
	}

	public Date getDatumVazenjaPonude() {
		return datumVazenjaPonude;
	}

	public void setDatumVazenjaPonude(Date datumVazenjaPonude) {
		this.datumVazenjaPonude = datumVazenjaPonude;
	}

	public int getRedniBrojPredracuna() {
		return redniBrojPredracuna;
	}

	public void setRedniBrojPredracuna(int redniBrojPredracuna) {
		this.redniBrojPredracuna = redniBrojPredracuna;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}